package chapter04;

public class Test04_polymorphism {
    public static void main(String[] args) {
        Dog2 d = new Dog2();
        d.shout();
        Cat1 c = new Cat1();
        c.shout();
        //定义父类对象 实现子类的实例化
        Animal2 a1 = new Dog2();
        Animal2 a2 = new Cat1();
        a1.shout();
        a2.shout();
    }
}
class Dog2 extends Animal2{
    @Override
    public void shout() {
        System.out.println("汪汪");
    }
}
class Cat1 extends Animal2{
    @Override
    public void shout() {
        System.out.println("喵喵");
    }
}
